<!--
 * @FilePath: \vue-typescript-admin-template\src\views\theme\index.vue
 * @Author: maskMan
 * @Date: 2023-04-09 20:16:27
 * @LastEditTime: 2023-04-18 16:47:57
 * @Reference: 引用方 src\layout\components\Sidebar\SidebarItem.vue
 * @Descripttion: 说明 换肤主题
-->

<template>
  <div class="app-container">
    <!-- 显示卡片 -->
    <el-card class="box-card">
      <!-- 标题头链接 -->
      <div slot="header">
        <a
          class="link-type link-title"
          target="_blank"
          href="https://armour.github.io/vue-typescript-admin-docs/guide/advanced/theme.html"
        >
          <!-- 说明文档 -->
          {{ $t('theme.documentation') }}
        </a>
      </div>
      <!-- 选项卡 -->
      <div class="box-item">
        <span class="field-label">{{ $t('theme.change') }} : </span>
        <el-switch v-model="theme" />
        <aside style="margin-top: 15px">
          {{ $t('theme.tips') }}
        </aside>
      </div>
    </el-card>
    <!-- 按钮 -->
    <div class="block">
      <el-button type="primary"> Primary </el-button>
      <el-button type="success"> Success </el-button>
      <el-button type="info"> Info </el-button>
      <el-button type="warning"> Warning </el-button>
      <el-button type="danger"> Danger </el-button>
    </div>
    <!-- 按钮 -->
    <div class="block">
      <el-button type="primary" icon="el-icon-edit" />
      <el-button type="primary" icon="el-icon-share" />
      <el-button type="primary" icon="el-icon-delete" />
      <el-button type="primary" icon="el-icon-search"> Search </el-button>
      <el-button type="primary">
        Upload
        <i class="el-icon-upload el-icon-right" />
      </el-button>
    </div>

    <div class="block">
      <el-tag
        v-for="tag in tags"
        :key="tag.type"
        :type="tag.type"
        class="tag-item"
      >
        {{ tag.name }}
      </el-tag>
    </div>
    <!-- 单选框 -->
    <div class="block">
      <el-radio-group v-model="radio">
        <el-radio :label="3"> Option A </el-radio>
        <el-radio :label="6"> Option B </el-radio>
        <el-radio :label="9"> Option C </el-radio>
      </el-radio-group>
    </div>
    <!-- 滑动条 -->
    <div class="block">
      <el-slider v-model="slideValue" />
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator'
import { toggleClass } from '@/utils'
import '@/assets/custom-theme/index.css' // the theme changed version element-ui css

@Component({
  name: 'Theme'
})
export default class extends Vue {
  private theme = false
  private tags = [
    { name: 'Tag One', type: '' },
    { name: 'Tag Two', type: 'info' },
    { name: 'Tag Three', type: 'success' },
    { name: 'Tag Four', type: 'warning' },
    { name: 'Tag Five', type: 'danger' }
  ]

  private slideValue = 50
  private radio = 3

  @Watch('theme')
  private onThemeChange() {
    // 切换自定义类
    toggleClass(document.body, 'custom-theme')
  }
}
</script>

<style lang="scss" scoped>
.field-label {
  vertical-align: middle;
}

.box-card {
  width: 400px;
  max-width: 100%;
  margin: 20px auto;
}

.block {
  padding: 30px 24px;
}

.tag-item {
  margin-right: 15px;
}
</style>
